import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    role: ['admin','editor']     will control the page role (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if fasle ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  { path: '/', component: _import('login/index'), hidden: true }, // 临时
  { path: '/login', component: _import('login/index'), hidden: true },
  { path: '/thanks', component: _import('thanks/index'), hidden: true },
  { path: '/resgister/index', component: _import('resgister/index'), hidden: true },
  { path: '/resgister/forgetPassword', component: _import('resgister/forgetPassword'), hidden: true },
  { path: '/authredirect', component: _import('login/authredirect'), hidden: true },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  { path: '/401', component: _import('errorPage/401'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: _import('dashboard/index'),
      name: 'dashboard',
      meta: { title: 'dashboard', tag: 'dashboard', icon: 'dashboard', noCache: true }
    }],
    hidden: true
  }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

// 权限路由总表
export const asyncRouterMap = [
  // {
  //   path: '/partner',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   name: 'partner',
  //   meta: {
  //     title: 'partner.title',
  //     icon: 'order'
  //   },
  //   roles: ['1', '2', '3', '4'],
  //   children: [
  //     { path: 'index', roles: ['1'], component: _import('partner/dashboard'), name: 'partner.index', meta: { title: 'partner.index', tag: 'partner.nameIndex', sign: 'partnerWork' }},
  //     { path: 'update/:id', component: _import('partner/update'), hidden: true, name: 'partner.update', meta: { title: 'partner.update', tag: 'partner.nameUpdate', sign: 'partnerWork' }},
  //     { path: 'view/:id', component: _import('partner/view'), hidden: true, name: 'partner.view', meta: { title: 'partner.view', tag: 'partner.nameView', sign: 'partnerWork' }},
  //     { path: 'add', component: _import('partner/add'), hidden: true, name: 'partner.add', meta: { title: 'partner.add', tag: 'partner.nameAdd', sign: 'partnerWork' }}
  //   ]
  // },
  // {
  //   path: '/science',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   name: 'science',
  //   meta: {
  //     title: 'science.title',
  //     icon: 'order'
  //   },
  //   roles: ['13', '14', '15', '16', '17', '18'],
  //   children: [
  //     { path: 'lesson-index', roles: ['13'], component: _import('science/lessonIndex'), name: 'science.lessonIndex', meta: { title: 'science.lessonIndex', tag: 'science.nameLessonIndex', sign: 'lessonWork' }},
  //     { path: 'lesson-view/:id', component: _import('science/lessonView'), hidden: true, name: 'science.lessonView', meta: { title: 'science.lessonView', tag: 'science.nameLessonView', sign: 'lessonWork' }},
  //     { path: 'lesson-edit/:id', component: _import('science/lessonEdit'), hidden: true, name: 'science.lessonEdit', meta: { title: 'science.lessonEdit', tag: 'science.nameLessonEdit', sign: 'lessonWork' }},
  //     { path: 'lesson-add', component: _import('science/lessonAdd'), hidden: true, name: 'science.lessonAdd', meta: { title: 'science.lessonAdd', tag: 'science.nameLessonAdd', sign: 'lessonWork' }},
  //     { path: 'lesson-configure', component: _import('science/lessonConfigure'), hidden: true, name: 'science.lessonConfigure', meta: { title: 'science.lessonConfigure', tag: 'science.nameLessonConfigure', sign: 'lessonWork' }},
  //     { path: 'tip-index', roles: ['17'], component: _import('science/tipIndex'), name: 'science.tipIndex', meta: { title: 'science.tipIndex', tag: 'science.nameTipIndex', sign: 'tipWork' }},
  //     { path: 'tip-edit/:id', component: _import('science/edit'), hidden: true, name: 'science.tipView', meta: { title: 'science.tipView', tag: 'science.nameTipView', sign: 'tipWork' }}
  //   ]
  // },
  // {
  //   path: '/user',
  //   component: Layout,
  //   redirect: 'noredirect',
  //   name: 'user',
  //   meta: {
  //     title: 'user.title',
  //     icon: 'order'
  //   },
  //   roles: ['19', '20'],
  //   children: [
  //     { path: 'index', roles: ['19'], component: _import('user/index'), name: 'user.index', meta: { title: 'user.index', tag: 'user.nameIndex', sign: 'userWork' }},
  //     { path: 'view/:id', component: _import('user/view'), hidden: true, name: 'user.view', meta: { title: 'user.view', tag: 'user.nameView', sign: 'userWork' }}
  //   ]
  // },
  {
    path: '/manager',
    component: Layout,
    redirect: 'noredirect',
    name: 'manager',
    roles: ['1'],
    meta: {
      title: 'manager.title',
      icon: 'user'
    },
    children: [
      { path: 'user-index', component: _import('manager/account'), name: 'manager.userIndex', meta: { title: 'manager.userIndex', tag: 'manager.nameUserIndex', sign: 'managerUser' }},
      { path: 'user-view/:id', component: _import('manager/personal'), hidden: true, name: 'manager.userView', meta: { title: 'manager.userView', tag: 'manager.nameUserView', sign: 'managerUser' }}
      // { path: 'auth-index', component: _import('manager/group'), roles: ['9'], name: 'manager.authIndex', meta: { title: 'manager.authIndex', tag: 'manager.nameAuthIndex', sign: 'managerAuth' }},
      // { path: 'auth-view/:id', component: _import('manager/group-view'), roles: ['10'], hidden: true, name: 'manager.authView', meta: { title: 'manager.authView', tag: 'manager.nameAuthView', sign: 'managerAuth' }},
      // { path: 'auth-add', component: _import('manager/group-add'), roles: ['11'], hidden: true, name: 'manager.authAdd', meta: { title: 'manager.authAdd', tag: 'manager.nameAuthAdd', sign: 'managerAuth' }},
      // { path: 'auth-update/:id', component: _import('manager/group-add'), roles: ['12'], hidden: true, name: 'manager.authUpdate', meta: { title: 'manager.authUpdate', tag: 'manager.nameAuthUpdate', sign: 'managerAuth' }}
    ]
  },
  {
    path: '/property',
    component: Layout,
    redirect: 'noredirect',
    name: 'property',
    roles: ['1'],
    meta: {
      title: 'property.title',
      icon: 'order'
    },
    children: [
      { path: 'prop-index', component: _import('property/propDash'), name: 'property.propIndex', meta: { title: 'property.propIndex', tag: 'property.namePropIndex', sign: 'propWork' }},
      { path: 'prop-attr', component: _import('property/propAttr'), name: 'property.propAttr', meta: { title: 'property.propAttr', tag: 'property.namePropAttr', sign: 'propWork' }}
    ]
  }
]
